package easy

import "workspace/node"

func TrimBST(root *node.TreeNode, low int, high int) *node.TreeNode {
	if root == nil {
		return nil
	}
	if root.Val < low {
		return TrimBST(root.Right, low, high)
	} else if root.Val > high {
		return TrimBST(root.Left, low, high)
	} else {
		root.Left = TrimBST(root.Left, low, high)
		root.Right = TrimBST(root.Right, low, high)
		return root
	}
}
